repair bad block

I'd go so far as to copy critical data to a thumbdrive before shutdown. (A disk just failed here that, while totally unreadable, still shows smartctl data with only the
spinup time unreasonable. ) The next boot and maybe no access to it. (Just restored
99 percent of the data yesterday, thanks to
Code:
rsync, fdisk with parameters from a file,
sysinstall, escape to loader prompt, bsdlabel, shell-saved-history, newfs, mkdir -p, chflags,
too complex to writeup except locally. (Not from the unreadable drive though.)
 
Bad blocks should be mapped out by drive firmware pretty much automatically. If you see a real bad block on a modern hard drive it means that the drive firmware has run out of spare blocks to use in place of bad blocks, throw the drive away and buy a new one.
 
I already have FreeBSD installed on my notebook, I want to test the new FreeBSD on my desktop, even though I lost 100GB, no problem.

I just want to test.
 
Are you saying you have a desktop drive with bad sectors? Write all zeros to it with dd until smartctl -a doesn't report any new reallocated sectors. Or just install FreeBSD. When a bad block is written, the drive should swap it out. Of course the drive could fail entirely at any moment.
 
When I install FreeBSD, there is a lot of error and restarts. Finally managed to install, I typed
Code:
[FILE]fsck -y[/FILE]
and is running many days.
 
Sounds like the drive is failing.
Run smartctl to check reallocated_sector_count:
# smartctl -a /dev/ad0

Then wipe the whole drive with zeros:
# dd if=/dev/zero of=/dev/ad0 bs=64k

Repeat that until reallocated_sector_count stops going up, or the drive fails.

Just out of curiosity, what brand of drive is this?
 
Western digital. This will erase the entire hard drive?
[cmd=]dd if=/dev/zero of=/dev/ad0 bs=64k[/cmd]

Is the same driver that is installed FreeBSD. I have to use a live CD? I'm not getting the system starts, it asks to do the fsck. fsck never ends.
 
douglasfim said:
western digital

this will erase the entire hard drive?
Code:
dd if=/dev/zero of=/dev/ad0 bs=64k

Yes.

The drive might be a different number, ad4 or ad6 or even ada0. That depends on the computer and version of FreeBSD.

is the same driver that is installed FreeBSD

Yes.

I have to use a live CD?

I'm not getting the system starts, it asks to do the fsck.

The first time, boot in single user mode. dd is in /bin and should be available. After you run it, everything will be gone and you'll have to use a live CD anyway. I recommend mfsBSD.

Realize that the fsck is showing that all those spots went bad after installing FreeBSD. That drive is probably not going to work much longer.
 
zfs is better to use this driver? mfsBSD is to install or to use only as liveCD. When installing FreeBSD have to format, or just install.
 
If the drive is failing, no filesystem can make up for that. If it's not failing, UFS is fine.

mfsBSD is a liveCD meant to be used for this kind of thing, not to install.
 
If ya must.

Boot LiveCD > dd > Boot Install CD > Install
If fails > repeat until your heart is content that the drive is truly JUNK!!

-Enjoy
fh : )_~
 
Running fsck on a brand new filesystem that was created on a disk that has just been wiped out entirely is pretty much useless.
Right after dd-ing the disk, run smartctl again (available on the mfsBSD disc) and see if things have changed (especially Reallocated_Sector_Ct, Current_Pending_Sector, Offline_Uncorrectable).
Do what wblock@ says in post #7.

Now if you only want to test FreeBSD and don't care about your disk potentially failing at any time, then just dd the disk and install FreeBSD. "Formatting" (i.e. running newfs) is done automatically when you install FreeBSD.
Note that the installation may return errors or completely fail depending on the status of the disk and the location of the bad blocks.
 
douglasfim said:
I'm confused.

dd > format > install > fsck

or

dd > fsck > format > install

Neither. fsck is to repair a filesystem, and there won't be anything left on the disk after dd finishes.

Run smartctl and look at the reallocated sector count.

dd zeros to the whole drive.
Check the reallocated sector count with smartctl again. If it has increased, use dd again.

Repeat until the reallocated sector count doesn't go up. Or until the drive dies, which is fairly likely.

If you manage to "fix" it, the reallocated sector count will stop going up. Then just reinstall as normal.
 
Linux has the command badblocks would have an equivalent in FreeBSD?

badsect is similar to the badblocks?
 
Yes, both are appropriate for 25-year-old drives that don't have error correction, and already have a filesystem on them. Is there some reason you can't run dd?
 
I am running dd ​​is so far running.

The smartctl saves everything in HD? after formatting will lose everything?
 
smartctl just reports the drive SMART information. Formatting (or dd) does not erase that information.
 
Back
Top